using Godot;


public partial class MoveState : State
{
    private Player _player;

    public override void Enter()
    {
        base.Enter();
        _player = SM.Target as Player;
        _player.StateLbl.Text = "Move";
    }

    public override void Update(double delta)
    {
        base.Update(delta);
        var direction = Input.GetVector("ui_left", "ui_right", "ui_up", "ui_down");
        _player.Velocity = _player.Velocity.MoveToward(direction * _player.Speed, _player.Friction * (float)delta);

        if (_player.Velocity.IsZeroApprox())
        {
            EmitSignal(SignalName.Switch, "Idle");
        }
    }

    public override void FixedUpdate(double delta)
    {
        base.FixedUpdate(delta);
        _player.MoveAndSlide();
    }
}
